Scheduler for UWP | ComponentOne
Features / Import and Export / Exporting Data
In This Topic
    Exporting Data
    In This Topic

    There are two ways you can allow end-users to export data from the C1Schedule control. One allows the user to select the location to which the files will be saved and the other allows you to set up the export to happen silently.

    If you want to handle exporting files in a Click event, and allow your user to select the location to which the C1Scheduler files will be saved, use the following code:

    C#
    Copy Code
    // opens Save File (system defined) dialog, allows customer to select where to save data and then exports all appointments there
    C1Scheduler.ExportCommand.Execute(null, sched1);
    

    You can also handle exporting data silently:

    To export data to a local XML or iCal file in the application folder, first, add the System.IO namespace at the top of your page.

    C#
    Copy Code
    using System.IO;
    

    Then place the following code in a Save Button click, Page Navigated From or Unloaded event.

    C#
    Copy Code
    // Export XML to app local folder
    var folder = Windows.Storage.ApplicationData.Current.LocalFolder;
    var file = await folder.CreateFileAsync("appointments.xml", Windows.Storage.CreationCollisionOption.OpenIfExists);
    IRandomAccessStream stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);
    await sched1.DataStorage.ExportAsync(stream.AsStreamForWrite(), C1.C1Schedule.FileFormatEnum.XML);
    await stream.FlushAsync();
    stream.Dispose();